import { defineStore } from "pinia"

export const useCounterStore = defineStore("counter", {
  // 只有state是一个函数的形式
  state: () => {
    return {
      count: 20,
    }
  },
  // pinia将vuex4再次精简,没有了mutations了
  actions: {
    changeCount(value) {
      this.count += value
    },
  },
  getters: {
    evenOrOdd() {
      return this.count % 2 == 0 ? "偶数" : "奇数"
    },
  },
})
